package com.dingreading.cloud.soms.service.impl;

import com.dingreading.cloud.soms.entity.ReaderContest;
import com.dingreading.cloud.soms.entity.table.ReaderContestTableDef;
import com.dingreading.cloud.soms.mapper.ReaderContestMapper;
import com.dingreading.cloud.soms.service.ReaderContestService;
import org.springframework.stereotype.Service;

/**
 *  服务层实现。
 *
 * @author Administrator
 * @since 2024-12-11
 */
@Service
public class ReaderContestServiceImpl extends BaseServiceImpl<ReaderContestMapper, ReaderContest, ReaderContestTableDef> implements ReaderContestService {

    @Override
    protected ReaderContestTableDef getTable() {
        return ReaderContestTableDef.readerContest;
    }

    @Override
    public ReaderContest getByUid(String uid) {
        return getMapper().selectOneByCondition(table.uid.eq(uid));
    }

    @Override
    public boolean existsByStaffUidAndType(String staffUid, Integer type) {
        return exists(table.addStaffUid.eq(staffUid).and(table.type.eq(type)));
    }

    @Override
    public ReaderContest getByStaffUidAndType(String staffUid, Integer type) {
        return getMapper().selectOneByCondition(table.addStaffUid.eq(staffUid).and(table.type.eq(type)));
    }

    @Override
    public boolean haveFinal(String staffUid) {
        return exists(table.addStaffUid.eq(staffUid).and(table.type.eq(1)).and(table.status.eq(1)));
    }
}
